Skip to content

fix(studio): a sealed move, resize or turn takes GSAP's route when GSAP animates the layer - #8286

Merged
miguel-heygen merged 3 commits into
mainfrom
fix/sealed-gsap-route
Nov 20, 2026
Merged

miguel-heygen merged 3 commits into
mainfrom
fix/sealed-gsap-route

Conversation

@miguel-heygen

@miguel-heygen miguel-heygen commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

What

In a sealed preview (Studio cannot script the frame), a move, resize or turn of a layer GSAP animates now goes into the animation, as it does in an unsealed preview:

  • a move made by the agent tools saves into the GSAP tween. Before, it saved a CSS translate on the element on top of the animation, so the animation still drew the layer where it was, and the edit stayed in the file as a hidden offset;
  • an X or Y typed in the inspector, for a layer whose animation Studio does not attribute to the selection, takes the same GSAP route;
  • a resize or turn that does not come from a drag (the agent, or a W, H or angle typed in the inspector) on a layer GSAP sizes or turns takes the GSAP route. Before, it wrote CSS width/height or rotate the animation overrides.

After an undo that the sealed preview restores in place (re-running the page's script), the next of these edits decides its route from the page as it is now. Before, it decided from the tweens read before the undo.

The sealed preview is off by default until the sealed-by-default change (#7846) lands, so nothing changes for anyone before then.

Why

Studio decides once per edit whether GSAP or CSS owns a layer's position, size or turn (editsPlainCss). It asks the element's own window for its GSAP timelines. In a sealed preview the element is Studio's stand-in, whose window has none, so every layer looked GSAP-free.

Studio already reads a sealed frame's GSAP: a snapshot of its timelines over the editing port, matched to stand-ins by handle. The property panel used it through sealedGsapRendersTransform, but the route decision did not.

How

  • editsPlainCss answers for a stand-in from the frame's snapshot, with the channel lists the live check uses (position, turn, and for a resize the box channels and scaleX/scaleY). A transform tween stands in for "GSAP renders the transform", which the snapshot does not report. sealedGsapRendersTransform folds into it: one decision.
  • editsPlainCssSettled reads the snapshot at the playhead before deciding, for a stand-in only; a live element answers at once, as before. The inspector's move and the GSAP-aware move, resize and turn commits use it when no press decided the route.
  • The snapshot drops and re-reads itself when an undo is restored in place (onPreviewRestoredInPlace), as it already did when the preview reloads.

A drag still decides at its press, from the frame's own read that a sealed press waits for (measurePreviewGestureStart, the core gesture-start request), not from the snapshot: a move and a resize's anchor take GSAP's route when the frame says GSAP positions the layer (start.gsap), a turn when it says GSAP turns it (start.gsapRotation), and a group move gets each member's answer the same way. The resize commit is handed that answer as its route.

A resize drag's release that saves its anchor move on the element, because only a shared tween positions the layer, reads the snapshot too (useGsapAwareEditing, plainAfterSettle): it now waits for it, as the commits above do. Before, a release before the frame's first snapshot staged a CSS translate on a layer GSAP positions. The press's undo look (readElementLook) asks synchronously, but a stand-in has no GSAP to read either way, so it decides nothing.

Test plan

gsapRoute.sealed.test.tsx, with the frame's snapshot served over a mocked port:

  • an X typed in the inspector takes GSAP's route, before the frame was ever read;
  • a move made by the agent takes GSAP's route;
  • a resize of a layer whose tween sets its width takes GSAP's route, while its move stays CSS;
  • after an undo restored in place re-ran the script, the route is decided from the new tweens;
  • a resize drag's anchor move, saved on the element because only a shared tween positions the layer, is staged on GSAP's marks before the frame was read.

fails without the fix:

  • with a stand-in routed by its own window, the first four fail;
  • with the route decided before the frame is read, the first four fail;
  • with an in-place restore keeping the old snapshot, "decides again from the frame after an undo restored in place re-ran its script" fails;
  • with the anchor move's route decided before the frame is read, "saves a resize's anchor move on GSAP's marks when only a shared tween positions the layer" fails.

Run on Linux: the new tests pass three runs in a row; Studio's hooks, components/editor, webmcp and components/sidebar tests (4109; hooks and components/editor again at this head, 3861) and the player tests (605) pass; Studio tsc no errors; format clean; the code audit passes.

Bench

Edit-accuracy bench, sealed, the move, resize and turn drags of layers GSAP animates (fromto, keys, scale) at r0, root, 100% zoom (27), at main and at this change:

preview cases accurate drop / reload / undo / redo / teleport misses failing cases
sealed, main 27 18 9 / 9 / 3 / 3 / 9 9
sealed, this change 27 18 9 / 9 / 3 / 3 / 9 11

Accuracy is the same case for case. The two extra failing cases (move-keys … on, rotate-scale … after) fail smooth only (frame pacing, reported and not gated; the machine's load was 10 to 16), and every geometry check in them passes on both sides. These are drags, which keep deciding at the press, so no change was expected. The misses on both sides are sealed resize drags of keys and scale layers and move drags of scale layers, tracked separately.

Before

Sealed preview, design-panel-qa fixture, whose #qa-tween-box GSAP moves and turns. The agent moves it to 400, 300 (at main). The save wrote a CSS translate on the element and left the tween alone; the box stays where the animation draws it.

before: the agent's move saved a CSS translate on the element; the box did not move

After

The same with this change: the move saved into the tween as keyframes, and the box sits at 400, 300 on its motion path.

after: the agent's move saved into the GSAP tween; the box moved along its path

Each side was run three times on a fresh copy of the fixture with the same result. A first Before run, read once after 3 s with a pattern that missed the reordered attributes, showed the keyframes; its reading is not counted.

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 271 (base branch 271), smooth 67 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (0)

Unstable (1)

  • seqplainkeys-none-px-r0-nested-z100: tracking 0.07, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.07, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.07, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true

@eddy-heygen eddy-heygen left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Eddy's agent) Reviewed by Eddy's Claude agent at commit 2952e87 (non-test diff read by me, including the commit added after 0616a88).

Verdict: approve.

Summary
In a sealed preview Studio decided "does the animation library own this layer's transform" by asking its own stand-in element, which never has one, so a move, resize or turn of an animated layer was written as plain CSS and then overwritten by the animation. The one routing function now recognises a stand-in and answers from the frame's snapshot of its timelines; the commit paths wait for that snapshot to be read at the playhead before choosing a route.

What I checked

  • An element of a live (unsealed) preview takes exactly the old path: the stand-in test is false and the existing check runs.
  • For a sealed frame the answer is "a tween writes a transform channel for this target" (transform or box channels for a resize). It errs toward the animation's route, which is the safe side for the bug described.
  • The three commit paths (move, resize, rotate) now await the settled answer only when no explicit route was passed; an explicit route still wins.
  • The move saved alongside a resize now waits for the same settled answer, so a layer positioned only by a shared tween keeps the animation's route there too.
  • The snapshot is dropped and re-read when an undo restores the preview in place, so a route is not chosen from a stale snapshot.
  • The separate sealed helper the property panel used is folded into the same function, so the panel and the commit agree.
  • No port request is added and nothing from the frame is written anywhere new; the frame's snapshot only picks between two existing write routes.

Non-blockers

  • A sealed frame's snapshot cannot say whether the animation actually renders the transform at this moment, only that a tween targets it, so a layer with a transform tween elsewhere on the timeline always takes the animation's route. The code comment says so.

CI: 57 pass, 20 skipped, none failing or pending.

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit 468ab90 Nov 20, 2026
86 of 87 checks passed
@miguel-heygen
miguel-heygen deleted the fix/sealed-gsap-route branch November 20, 2026 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants